/******************************************************************************
 * Copyright 2023 The Apollo Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *****************************************************************************/

#include "modules/canbus_vehicle/x3epro/protocol/vcu_vehicle_fault_response_201.h"
#include "glog/logging.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"

namespace apollo {
namespace canbus {
namespace x3epro {

using ::apollo::drivers::canbus::Byte;

Vcuvehiclefaultresponse201::Vcuvehiclefaultresponse201() {}
const int32_t Vcuvehiclefaultresponse201::ID = 0x201;

void Vcuvehiclefaultresponse201::Parse(const std::uint8_t* bytes, int32_t length,
                         X3epro* chassis) const {
  chassis->mutable_vcu_vehicle_fault_response_201()->set_vehicle_error_indicationsvcu(vehicle_error_indicationsvcu(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_brake_system_errorehb(brake_system_errorehb(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_eps_error(eps_error(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_motor_error(motor_error(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_epb_error(epb_error(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_high_voltage_battery_errorbcu(high_voltage_battery_errorbcu(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_automode_exit_reason_losscommunication_with_adu(automode_exit_reason_losscommunication_with_adu(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_automode_exit_reason_reqsignalnotsatistied(automode_exit_reason_reqsignalnotsatistied(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_automode_exit_reason_low_power(automode_exit_reason_low_power(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_automode_exit_reason_highvolt(automode_exit_reason_highvolt(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_automode_exit_reason_vehicle_flt(automode_exit_reason_vehicle_flt(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_automode_exit_reason_press_emergency_button(automode_exit_reason_press_emergency_button(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_automode_exit_reason_press_remote_control(automode_exit_reason_press_remote_control(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_automode_exit_reason_pdu_control(automode_exit_reason_pdu_control(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_vcu_faultrept_alivecounter(vcu_faultrept_alivecounter(bytes, length));
  chassis->mutable_vcu_vehicle_fault_response_201()->set_vcu_faultrept_checksum(vcu_faultrept_checksum(bytes, length));
}

// config detail: {'bit': 3, 'enum': {0: 'VEHICLE_ERROR_INDICATIONSVCU_NO_ERROR', 1: 'VEHICLE_ERROR_INDICATIONSVCU_LEVEL_1_ERROR', 2: 'VEHICLE_ERROR_INDICATIONSVCU_LEVEL_2_ERROR', 3: 'VEHICLE_ERROR_INDICATIONSVCU_LEVEL_3_ERROR', 4: 'VEHICLE_ERROR_INDICATIONSVCU_LEVEL_4_ERROR', 5: 'VEHICLE_ERROR_INDICATIONSVCU_LEVEL_5_ERROR'}, 'is_signed_var': False, 'len': 4, 'name': 'vehicle_error_indicationsvcu', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Vehicle_error_indicationsvcuType Vcuvehiclefaultresponse201::vehicle_error_indicationsvcu(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 0);
  int32_t x = t0.get_byte(0, 4);

  Vcu_vehicle_fault_response_201::Vehicle_error_indicationsvcuType ret =  static_cast<Vcu_vehicle_fault_response_201::Vehicle_error_indicationsvcuType>(x);
  return ret;
}

// config detail: {'bit': 7, 'enum': {0: 'BRAKE_SYSTEM_ERROREHB_NO_ERROR', 1: 'BRAKE_SYSTEM_ERROREHB_LEVEL_1_ERROR', 2: 'BRAKE_SYSTEM_ERROREHB_LEVEL_2_ERROR', 3: 'BRAKE_SYSTEM_ERROREHB_LEVEL_3_ERROR', 4: 'BRAKE_SYSTEM_ERROREHB_LEVEL_4_ERROR', 5: 'BRAKE_SYSTEM_ERROREHB_LEVEL_5_ERROR'}, 'is_signed_var': False, 'len': 4, 'name': 'brake_system_errorehb', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Brake_system_errorehbType Vcuvehiclefaultresponse201::brake_system_errorehb(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 0);
  int32_t x = t0.get_byte(4, 4);

  Vcu_vehicle_fault_response_201::Brake_system_errorehbType ret =  static_cast<Vcu_vehicle_fault_response_201::Brake_system_errorehbType>(x);
  return ret;
}

// config detail: {'bit': 11, 'enum': {0: 'EPS_ERROR_NO_ERROR', 1: 'EPS_ERROR_LEVEL_1_ERROR', 2: 'EPS_ERROR_LEVEL_2_ERROR', 3: 'EPS_ERROR_LEVEL_3_ERROR', 4: 'EPS_ERROR_LEVEL_4_ERROR', 5: 'EPS_ERROR_LEVEL_5_ERROR'}, 'is_signed_var': False, 'len': 4, 'name': 'eps_error', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Eps_errorType Vcuvehiclefaultresponse201::eps_error(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 1);
  int32_t x = t0.get_byte(0, 4);

  Vcu_vehicle_fault_response_201::Eps_errorType ret =  static_cast<Vcu_vehicle_fault_response_201::Eps_errorType>(x);
  return ret;
}

// config detail: {'bit': 15, 'enum': {0: 'MOTOR_ERROR_NO_ERROR', 1: 'MOTOR_ERROR_LEVEL_1_ERROR', 2: 'MOTOR_ERROR_LEVEL_2_ERROR', 3: 'MOTOR_ERROR_LEVEL_3_ERROR', 4: 'MOTOR_ERROR_LEVEL_4_ERROR', 5: 'MOTOR_ERROR_LEVEL_5_ERROR'}, 'is_signed_var': False, 'len': 4, 'name': 'motor_error', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Motor_errorType Vcuvehiclefaultresponse201::motor_error(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 1);
  int32_t x = t0.get_byte(4, 4);

  Vcu_vehicle_fault_response_201::Motor_errorType ret =  static_cast<Vcu_vehicle_fault_response_201::Motor_errorType>(x);
  return ret;
}

// config detail: {'bit': 19, 'enum': {0: 'EPB_ERROR_NO_ERROR', 1: 'EPB_ERROR_LEVEL_1_ERROR', 2: 'EPB_ERROR_LEVEL_2_ERROR', 3: 'EPB_ERROR_LEVEL_3_ERROR', 4: 'EPB_ERROR_LEVEL_4_ERROR', 5: 'EPB_ERROR_LEVEL_5_ERROR'}, 'is_signed_var': False, 'len': 4, 'name': 'epb_error', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Epb_errorType Vcuvehiclefaultresponse201::epb_error(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 2);
  int32_t x = t0.get_byte(0, 4);

  Vcu_vehicle_fault_response_201::Epb_errorType ret =  static_cast<Vcu_vehicle_fault_response_201::Epb_errorType>(x);
  return ret;
}

// config detail: {'bit': 23, 'enum': {0: 'HIGH_VOLTAGE_BATTERY_ERRORBCU_NO_ERROR', 1: 'HIGH_VOLTAGE_BATTERY_ERRORBCU_LEVEL_1_ERROR', 2: 'HIGH_VOLTAGE_BATTERY_ERRORBCU_LEVEL_2_ERROR', 3: 'HIGH_VOLTAGE_BATTERY_ERRORBCU_LEVEL_3_ERROR', 4: 'HIGH_VOLTAGE_BATTERY_ERRORBCU_LEVEL_4_ERROR', 5: 'HIGH_VOLTAGE_BATTERY_ERRORBCU_LEVEL_5_ERROR'}, 'is_signed_var': False, 'len': 4, 'name': 'high_voltage_battery_errorbcu', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::High_voltage_battery_errorbcuType Vcuvehiclefaultresponse201::high_voltage_battery_errorbcu(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 2);
  int32_t x = t0.get_byte(4, 4);

  Vcu_vehicle_fault_response_201::High_voltage_battery_errorbcuType ret =  static_cast<Vcu_vehicle_fault_response_201::High_voltage_battery_errorbcuType>(x);
  return ret;
}

// config detail: {'bit': 32, 'enum': {0: 'AUTOMODE_EXIT_REASON_LOSSCOMMUNICATION_WITH_ADU_NORMAL', 1: 'AUTOMODE_EXIT_REASON_LOSSCOMMUNICATION_WITH_ADU_FAILURE'}, 'is_signed_var': False, 'len': 1, 'name': 'automode_exit_reason_losscommunication_with_adu', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Automode_exit_reason_losscommunication_with_aduType Vcuvehiclefaultresponse201::automode_exit_reason_losscommunication_with_adu(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 4);
  int32_t x = t0.get_byte(0, 1);

  Vcu_vehicle_fault_response_201::Automode_exit_reason_losscommunication_with_aduType ret =  static_cast<Vcu_vehicle_fault_response_201::Automode_exit_reason_losscommunication_with_aduType>(x);
  return ret;
}

// config detail: {'bit': 33, 'enum': {0: 'AUTOMODE_EXIT_REASON_REQSIGNALNOTSATISTIED_NORMAL', 1: 'AUTOMODE_EXIT_REASON_REQSIGNALNOTSATISTIED_FAILURE'}, 'is_signed_var': False, 'len': 1, 'name': 'automode_exit_reason_reqsignalnotsatistied', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Automode_exit_reason_reqsignalnotsatistiedType Vcuvehiclefaultresponse201::automode_exit_reason_reqsignalnotsatistied(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 4);
  int32_t x = t0.get_byte(1, 1);

  Vcu_vehicle_fault_response_201::Automode_exit_reason_reqsignalnotsatistiedType ret =  static_cast<Vcu_vehicle_fault_response_201::Automode_exit_reason_reqsignalnotsatistiedType>(x);
  return ret;
}

// config detail: {'bit': 34, 'enum': {0: 'AUTOMODE_EXIT_REASON_LOW_POWER_NORMAL', 1: 'AUTOMODE_EXIT_REASON_LOW_POWER_FAILURE'}, 'is_signed_var': False, 'len': 1, 'name': 'automode_exit_reason_low_power', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Automode_exit_reason_low_powerType Vcuvehiclefaultresponse201::automode_exit_reason_low_power(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 4);
  int32_t x = t0.get_byte(2, 1);

  Vcu_vehicle_fault_response_201::Automode_exit_reason_low_powerType ret =  static_cast<Vcu_vehicle_fault_response_201::Automode_exit_reason_low_powerType>(x);
  return ret;
}

// config detail: {'bit': 35, 'enum': {0: 'AUTOMODE_EXIT_REASON_HIGHVOLT_NORMAL', 1: 'AUTOMODE_EXIT_REASON_HIGHVOLT_FAILURE'}, 'is_signed_var': False, 'len': 1, 'name': 'automode_exit_reason_highvolt', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Automode_exit_reason_highvoltType Vcuvehiclefaultresponse201::automode_exit_reason_highvolt(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 4);
  int32_t x = t0.get_byte(3, 1);

  Vcu_vehicle_fault_response_201::Automode_exit_reason_highvoltType ret =  static_cast<Vcu_vehicle_fault_response_201::Automode_exit_reason_highvoltType>(x);
  return ret;
}

// config detail: {'bit': 36, 'enum': {0: 'AUTOMODE_EXIT_REASON_VEHICLE_FLT_NORMAL', 1: 'AUTOMODE_EXIT_REASON_VEHICLE_FLT_FAILURE'}, 'is_signed_var': False, 'len': 1, 'name': 'automode_exit_reason_vehicle_flt', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Automode_exit_reason_vehicle_fltType Vcuvehiclefaultresponse201::automode_exit_reason_vehicle_flt(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 4);
  int32_t x = t0.get_byte(4, 1);

  Vcu_vehicle_fault_response_201::Automode_exit_reason_vehicle_fltType ret =  static_cast<Vcu_vehicle_fault_response_201::Automode_exit_reason_vehicle_fltType>(x);
  return ret;
}

// config detail: {'bit': 37, 'enum': {0: 'AUTOMODE_EXIT_REASON_PRESS_EMERGENCY_BUTTON_NORMAL', 1: 'AUTOMODE_EXIT_REASON_PRESS_EMERGENCY_BUTTON_FAILURE'}, 'is_signed_var': False, 'len': 1, 'name': 'automode_exit_reason_press_emergency_button', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Automode_exit_reason_press_emergency_buttonType Vcuvehiclefaultresponse201::automode_exit_reason_press_emergency_button(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 4);
  int32_t x = t0.get_byte(5, 1);

  Vcu_vehicle_fault_response_201::Automode_exit_reason_press_emergency_buttonType ret =  static_cast<Vcu_vehicle_fault_response_201::Automode_exit_reason_press_emergency_buttonType>(x);
  return ret;
}

// config detail: {'bit': 38, 'enum': {0: 'AUTOMODE_EXIT_REASON_PRESS_REMOTE_CONTROL_NORMAL', 1: 'AUTOMODE_EXIT_REASON_PRESS_REMOTE_CONTROL_FAILURE'}, 'is_signed_var': False, 'len': 1, 'name': 'automode_exit_reason_press_remote_control', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Automode_exit_reason_press_remote_controlType Vcuvehiclefaultresponse201::automode_exit_reason_press_remote_control(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 4);
  int32_t x = t0.get_byte(6, 1);

  Vcu_vehicle_fault_response_201::Automode_exit_reason_press_remote_controlType ret =  static_cast<Vcu_vehicle_fault_response_201::Automode_exit_reason_press_remote_controlType>(x);
  return ret;
}

// config detail: {'bit': 39, 'enum': {0: 'AUTOMODE_EXIT_REASON_PDU_CONTROL_NORMAL', 1: 'AUTOMODE_EXIT_REASON_PDU_CONTROL_FAILURE'}, 'is_signed_var': False, 'len': 1, 'name': 'automode_exit_reason_pdu_control', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
Vcu_vehicle_fault_response_201::Automode_exit_reason_pdu_controlType Vcuvehiclefaultresponse201::automode_exit_reason_pdu_control(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 4);
  int32_t x = t0.get_byte(7, 1);

  Vcu_vehicle_fault_response_201::Automode_exit_reason_pdu_controlType ret =  static_cast<Vcu_vehicle_fault_response_201::Automode_exit_reason_pdu_controlType>(x);
  return ret;
}

// config detail: {'bit': 51, 'is_signed_var': False, 'len': 4, 'name': 'vcu_faultrept_alivecounter', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'}
int Vcuvehiclefaultresponse201::vcu_faultrept_alivecounter(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 6);
  int32_t x = t0.get_byte(0, 4);

  int ret = x;
  return ret;
}

// config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': 'vcu_faultrept_checksum', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'}
int Vcuvehiclefaultresponse201::vcu_faultrept_checksum(const std::uint8_t* bytes, int32_t length) const {
  Byte t0(bytes + 7);
  int32_t x = t0.get_byte(0, 8);

  int ret = x;
  return ret;
}
}  // namespace x3epro
}  // namespace canbus
}  // namespace apollo
